home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / TCOMPL~1.FRM < prev    next >
Text File  |  1997-06-14  |  5KB  |  160 lines

  1. VERSION 5.00
  2. Object = "{2DD06898-E157-11D0-8C51-00C04FC29CEC}#1.1#0"; "ListBoxPlus.ocx"
  3. Begin VB.Form FCompletion 
  4.    Caption         =   "Test Word Completion"
  5.    ClientHeight    =   3195
  6.    ClientLeft      =   915
  7.    ClientTop       =   1470
  8.    ClientWidth     =   4905
  9.    Icon            =   "TCompletion.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3195
  12.    ScaleWidth      =   4905
  13.    Begin VB.TextBox txtLookup 
  14.       BeginProperty Font 
  15.          Name            =   "Times New Roman"
  16.          Size            =   8.25
  17.          Charset         =   0
  18.          Weight          =   400
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   315
  24.       Left            =   240
  25.       TabIndex        =   1
  26.       Top             =   240
  27.       Width           =   1965
  28.    End
  29.    Begin ListBoxPlus.XListBoxPlus list 
  30.       Height          =   2205
  31.       Left            =   240
  32.       TabIndex        =   0
  33.       Top             =   705
  34.       Width           =   1965
  35.       _ExtentX        =   3466
  36.       _ExtentY        =   3889
  37.       BackColor       =   16777215
  38.       ForeColor       =   -2147483640
  39.       HiToLo          =   0   'False
  40.       SortMode        =   2
  41.       ListCount       =   11
  42.       List0           =   "abacus"
  43.       ItemData0       =   0
  44.       List1           =   "absolutely"
  45.       ItemData1       =   0
  46.       List2           =   "abstract"
  47.       ItemData2       =   0
  48.       List3           =   "h"
  49.       ItemData3       =   0
  50.       List4           =   "he"
  51.       ItemData4       =   0
  52.       List5           =   "hell"
  53.       ItemData5       =   0
  54.       List6           =   "hello"
  55.       ItemData6       =   0
  56.       List7           =   "one"
  57.       ItemData7       =   0
  58.       List8           =   "onerous"
  59.       ItemData8       =   0
  60.       List9           =   "only"
  61.       ItemData9       =   0
  62.       List10          =   "ontological"
  63.       ItemData10      =   0
  64.       ListIndex       =   -1
  65.       Completion      =   0   'False
  66.    End
  67.    Begin VB.Label Label1 
  68.       Caption         =   "Press Return in list box to complete the current word."
  69.       BeginProperty Font 
  70.          Name            =   "MS Sans Serif"
  71.          Size            =   8.25
  72.          Charset         =   0
  73.          Weight          =   700
  74.          Underline       =   0   'False
  75.          Italic          =   0   'False
  76.          Strikethrough   =   0   'False
  77.       EndProperty
  78.       Height          =   735
  79.       Index           =   2
  80.       Left            =   2400
  81.       TabIndex        =   4
  82.       Top             =   1680
  83.       Width           =   2295
  84.    End
  85.    Begin VB.Label Label1 
  86.       Caption         =   "Press Esc in text box to complete the current word."
  87.       BeginProperty Font 
  88.          Name            =   "MS Sans Serif"
  89.          Size            =   8.25
  90.          Charset         =   0
  91.          Weight          =   700
  92.          Underline       =   0   'False
  93.          Italic          =   0   'False
  94.          Strikethrough   =   0   'False
  95.       EndProperty
  96.       Height          =   735
  97.       Index           =   1
  98.       Left            =   2400
  99.       TabIndex        =   3
  100.       Top             =   960
  101.       Width           =   2295
  102.    End
  103.    Begin VB.Label Label1 
  104.       Caption         =   "Type in text box or list box. "
  105.       BeginProperty Font 
  106.          Name            =   "MS Sans Serif"
  107.          Size            =   8.25
  108.          Charset         =   0
  109.          Weight          =   700
  110.          Underline       =   0   'False
  111.          Italic          =   0   'False
  112.          Strikethrough   =   0   'False
  113.       EndProperty
  114.       Height          =   375
  115.       Index           =   0
  116.       Left            =   2400
  117.       TabIndex        =   2
  118.       Top             =   240
  119.       Width           =   2055
  120.    End
  121. End
  122. Attribute VB_Name = "FCompletion"
  123. Attribute VB_GlobalNameSpace = False
  124. Attribute VB_Creatable = False
  125. Attribute VB_PredeclaredId = True
  126. Attribute VB_Exposed = False
  127. Private Sub Form_Load()
  128.     list.Completion = True
  129.     list.SortMode = esmlSortText
  130. End Sub
  131.  
  132. Private Sub list_KeyPress(KeyAscii As Integer)
  133.     If KeyAscii = 13 Then
  134.         txtLookup = list.Text
  135.     Else
  136.         txtLookup = list.PartialWord
  137.         txtLookup.Refresh
  138.     End If
  139. End Sub
  140.  
  141. Private Sub txtLookup_KeyPress(KeyAscii As Integer)
  142.     Select Case KeyAscii
  143.     ' Use Esc key to complete word
  144.     Case 27
  145.         KeyAscii = 0
  146.         txtLookup = list.Text
  147.         txtLookup.SelStart = Len(txtLookup)
  148.         txtLookup.SelLength = 0
  149.     ' Disable Enter key
  150.     Case 13
  151.         KeyAscii = 0
  152.     End Select
  153. End Sub
  154.  
  155. Private Sub txtLookup_KeyUp(KeyCode As Integer, Shift As Integer)
  156.     If KeyCode <> 27 Then
  157.         list.PartialWord = txtLookup
  158.     End If
  159. End Sub
  160.